package com.qzsoft.fileServers.dao;

import com.qzsoft.fileServers.entity.File;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface FileDao {

    /**
     * 把前端传入的文件保存到mongodb里面
     * @param file 文件
     * @return
     */
    @Insert("insert into file(id, name, creatTime, type) values(#{id}, #{name}, #{creatTime}, #{type})")
    public void save(File file);

    /**
     * 根据ID获取文件实体类
     * @param id
     */
    @Select("SELECT * FROM file WHERE id = #{id}")
    public File getById(String id);

    /**
     * 根据id删除文件信息
     * @param id
     * @return
     */
    @Delete("DELETE FROM file WHERE id = #{id} ")
    public void delete(String id);
}
